package com.example.shortmessage.presenter;

import android.content.Context;

import com.example.shortmessage.contract.DetailsContract;
import com.example.shortmessage.dao.ObtainShortMessage;
import com.example.shortmessage.data.entity.MessageData;
import com.example.shortmessage.model.DetailsModel;
import com.example.shortmessage.utils.ReadPhoneStatusUtils;

import java.util.List;

public class DetailsPresenter extends DetailsContract.Presenter<DetailsContract.View> {

    private final DetailsModel model;
    private Context context;
    public DetailsPresenter(Context context) {
        this.context = context;
        model = new DetailsModel();
    }

    @Override
    public void release() {

    }

    @Override
    public List<MessageData> getData(String number) {

        return model.query(number);
    }

    @Override
    public void sendMessage(String number,String message) {
        ReadPhoneStatusUtils readPhoneStatusUtils = new ReadPhoneStatusUtils();
        if(readPhoneStatusUtils.validatePhone(context,number,message)){
            ObtainShortMessage.send(context,number,message);
        }
    }
}
